import request from '@/utils/request'

// 查员工简单数据列表
export const getEmployeeSimpleData = () => {
  return request({
    url: '/sys/user/simple',
    method: 'GET'
  })
}

// 获取员工列表
export const getUserListData = params => {
  return request({
    url: '/sys/user',
    method: 'GET',
    params
  })
}

// 获取员工基本信息
export const getUserInfoData = id => {
  return request({
    url: '/sys/user/' + id,
    method: 'GET'
  })
}

// 增加员工
export const addUserData = data => {
  return request({
    url: '/sys/user',
    method: 'POST',
    data
  })
}

// 修改员工基本信息
export const editUserData = data => {
  return request({
    url: '/sys/user/' + data.id,
    method: 'PUT',
    data
  })
}

// 删除员工
export const delUsertData = id => {
  return request({
    url: '/sys/user/' + id,
    method: 'DELETE'
  })
}

// 批量导入员工
export const importEmployees = data => {
  return request({
    url: '/sys/user/batch',
    method: 'POST',
    data
  })
}

/** *
 *  读取用户详情的基础信息
 * **/
export function getPersonalDetail(id) {
  return request({
    url: `/employees/${id}/personalInfo`
  })
}

/** *
 *  更新用户详情的基础信息
 * **/
export function updatePersonal(data) {
  return request({
    url: `/employees/${data.userId}/personalInfo`,
    method: 'put',
    data
  })
}

/** **
 * 获取用户的岗位信息
 *
 * ****/
export function getJobDetail(id) {
  return request({
    url: `/employees/${id}/jobs`
  })
}

/**
 * 保存岗位信息
 * ****/
export function updateJob(data) {
  return request({
    url: `/employees/${data.userId}/jobs`,
    method: 'put',
    data
  })
}
